#include "mybuttons.h"
#include "ui_mybuttons.h"

#include<QtDebug>

MyButtons::MyButtons(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MyButtons)
{
    ui->setupUi(this);
}

MyButtons::~MyButtons()
{
    delete ui;
}

void MyButtons::initButtonImage()
{
   //初始化按钮的图像
   ui->startButton->setImage(":/images/start-1.png",":/images/start-2.png",":/images/start-3.png");
   //叫地主
   ui->grapButtonn->setImage(":/images/qiangdizhu.png",":/images/qiangdizhu.png",":/images/qiangdizhu.png");
   ui->notGrapButton->setImage(":/images/buqiang-1.png",":/images/buqiang-2.png",":/images/buqiang-3.png");
   ui->onePoint->setImage(":/images/1fen-1.png",":/images/1fen-2.png",":/images/1fen-3.png");
   ui->twoPoint->setImage(":/images/2fen-1.png",":/images/2fen-2.png",":/images/2fen-3.png");
   ui->threePoint->setImage(":/images/3fen-1.png",":/images/3fen-2.png",":/images/3fen-3.png");
   //出牌
   ui->playCard->setImage(":/images/chupai_btn-1.png",":/images/chupai_btn-2.png",":/images/chupai_btn-3.png");
   ui->playCard2->setImage(":/images/chupai_btn-1.png",":/images/chupai_btn-2.png",":/images/chupai_btn-3.png");
   ui->NotPlayCard->setImage(":/images/pass_btn-1.png",":/images/pass_btn-2.png",":/images/pass_btn-3.png");

   //设置不同的组设置页面号
    QVector<MyButton*>buttons;
    buttons<<ui->startButton<<ui->grapButtonn<<ui->notGrapButton<<ui->onePoint<<ui->twoPoint<<ui->threePoint
          <<ui->playCard<<ui->playCard2<<ui->NotPlayCard;
   //按钮设置大小
    for(int i = 0;i<buttons.size();i++)
    {
        buttons[i]->setFixedSize(QSize(90,45));
    }
    //关联信号
    connect(ui->startButton,&QPushButton::clicked,this,[=](){this->StartGame();});
    connect(ui->grapButtonn,&QPushButton::clicked,this,[=](){this->GrapLander();});
    connect(ui->playCard,&QPushButton::clicked,this,[=](){this->PlayCardOne();});
    connect(ui->playCard2,&QPushButton::clicked,this,[=](){this->PlayCardTwo();});
    //抢分或者放弃抢分
    connect(ui->notGrapButton,&QPushButton::clicked,this,[=](){emit betPoint(0);});
    connect(ui->onePoint,&QPushButton::clicked,this,[=](){emit betPoint(1);});
    connect(ui->twoPoint,&QPushButton::clicked,this,[=](){emit betPoint(2);});
    connect(ui->threePoint,&QPushButton::clicked,this,[=](){emit betPoint(3);});
}

void MyButtons::selectGroup(MyButtons::GroupPage page)
{
    ui->ButtonGroups->setCurrentIndex((int)page);
}

void MyButtons::StartGame()
{

}

void MyButtons::GrapLander()
{

}

void MyButtons::PlayCardOne()
{

}

void MyButtons::PlayCardTwo()
{

}


